﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using nyxwin.Main.Base.ViewModels;
using nyxwin.Common.Silverlight.Commands;
using nyxwin.Common.Providers;

namespace nyxwin.Main.ViewModel.SubModels
{
    public class ActiveViewModel : BaseViewModel
    {
        public ActiveViewModel(Data.Common.Active active)
        {
            this.LastActivity = active.LastActivity;
            this.Location = active.Location;
            this.LocationUrl = active.LocationUrl;

            this.LocationCommand = new Command(x =>
            {
                LinkHandler.Instance.FollowLink(this.LocationUrl);
            },
            x =>
            {
                return Location != null;
            });
        }

        public string Location { get; private set; }
        public string LocationUrl { get; private set; }
        public TimeSpan LastActivity { get; private set; }

        public string LastActivityFormat
        {
            get
            {
                var la = LastActivity;
                return string.Format("[{0}:{1}{2}]", la.Minutes, la.Seconds < 10 ? "0" : "", la.Seconds);
            }
        }

        public Visibility LocationVisibility { get { return (Location != null) ? Visibility.Visible : Visibility.Collapsed; } }

        public Command LocationCommand { get; private set; }
    }
}
